hysop.backend.host.python.operator.min_max module¶
- class hysop.backend.host.python.operator.min_max.PythonMinMaxFieldStatistics(**kwds)[source]¶
Bases:
MinMaxFieldStatisticsBase
,HostOperator
Python implementation backend of operator MinMaxFieldStatistics.
See MinMaxFieldStatisticsBase.__init__().
- apply(**kwds)¶
Abstract method that should be implemented. Applies this node (operator, computational graph operator…).
- class hysop.backend.host.python.operator.min_max.PythonMinMaxFiniteDifferencesDerivativeStatistics(F, dF=None, A=None, derivative=None, direction=None, Fmin=None, Fmax=None, Finf=None, coeffs=None, all_quiet=False, name=None, pretty_name=None, pbasename=None, ppbasename=None, variables=None, **kwds)[source]¶
Bases:
MinMaxDerivativeStatisticsBase
,PythonFiniteDifferencesSpaceDerivative
Python implementation backend of operator MinMaxFiniteDifferencesDerivativeStatistics.
Initialize an MinMaxDerivativeStatisticsBase.
- MinMaxDerivativeStatistics can compute some commonly required Field derivative statistics:
Fmin: min value of a derivative of the field. Fmax: max value of a derivative of the field. Finf: max value of the absolute value of a
derivative of the field (computed using Fmin and Fmax).
First compute the derivative of a scalar field F in a given direction at a given order and on a given backend out of place in a specific output scalar field dF. The derivative is then possibly scaled by another field/parameter/value A.
After the scaled derivative has been computed, compute user requested statistics (min and max values) on this new field and scale those statistics by other scaling parameters stored in coeffs.
- Compute derivative
dF = alpha * d^n(F)/dXj**n
- where F is an input field
dF is an output field (by default a temporary field). n = derivative order > 0 alpha = A, where A is a Field, a Parameter or a scalar. Fmin = created or supplied TensorParameter. Fmax = created or supplied TensorParameter. Finf = created or supplied TensorParameter. Smin = coeffs[‘Fmin’] Smax = coeffs[‘Fmax’] Sinf = coeffs[‘Finf’]
- Statistics are only computed if explicitely requested by user,
unless required to compute another user-required statistic, see Notes.
- Parameters:
F (hysop.field.continuous_field.Field) – Continuous field as input.
dF (hysop.field.continuous_field.Field, optional) – Continuous field to be written. Some backend may allow inplace differentiation. By default a temporary scalar field is created, which means that the computation of the derivative may be discarded after this operator has been applied because of temporary buffer sharing between operators.
A (numerical value, ScalarParameter or Field, optional) – Scaling field/parameter/value for convenience. Defaults to no scaling.
derivative (int, optional) – Which derivative to generate. Defaults to 1.
direction (int, optional) – Directions in which to take the derivative. Defaults to 0.
F... (TensorParameter) – The output parameters that will contain the statistics. At least one statistic should be specified (either by boolean or TensorParameter). TensorParameters should be of shape (1,). If set to True, the TensorParameter will be generated automatically. Autogenerated TensorParameters that are not required by the user (ie. left to None or False during __init__) are, if required, generated but set to be quiet. Autogenerated parameters can be retrieved using the ‘Fmin’, ‘Fmax’ and ‘Finf’ attributes.
all_quiet (bool, optional defaults to False) – Set all autogenerated TensorParameter views to be quiet.
coeffs (dict of array like of coefficients, optional) – Optional scaling of the statistics. Scaling factor should be a scalar or an array-like of scalars for each components. If not given, defaults to 1 for all statistics.
name (str, optional) – Name of this operator.
pretty_name (str, optional) – Pretty name of this operator.
pbasename (str, optional) – Parameters basename for created parameters. Defaults to field.name.
ppbasename (str, optional) – Parameters pretty basename for created parameters. Defaults to pbasename.
variables (dict, optional) – Dictionary of fields as keys and topologies as values.
implementation (hysop.constants.Implementation, optional) – Specify underlying backend implementation. Target implementation, should be contained in available_implementations(). If None, implementation will be set to default_implementation().
base_kwds (dict, optional) – Base class keyword arguments as a dictionnary.
kwds – Extra keyword arguments passed towards operator backend implementation.
Attributes
-----------
F... – All generated tensor parameters. Unused statistics are set to None.
Notes
- About statistics:
- Finf requires to compute Fmin and Fmax and will have value:
Finf = Sinf * max( abs(Smin*Fmin), abs(Smax*Fmax))
where Sinf, Smin and Smax are the scaling coefficients defined in coeffs.
- apply(**kwds)¶
Abstract method that should be implemented. Applies this node (operator, computational graph operator…).
- class hysop.backend.host.python.operator.min_max.PythonMinMaxSpectralDerivativeStatistics(F, dF=None, A=None, derivative=None, direction=None, Fmin=None, Fmax=None, Finf=None, coeffs=None, all_quiet=False, name=None, pretty_name=None, pbasename=None, ppbasename=None, variables=None, **kwds)[source]¶
Bases:
MinMaxDerivativeStatisticsBase
,PythonSpectralSpaceDerivative
Python implementation backend of operator MinMaxSpectralDerivativeStatistics.
Initialize an MinMaxDerivativeStatisticsBase.
- MinMaxDerivativeStatistics can compute some commonly required Field derivative statistics:
Fmin: min value of a derivative of the field. Fmax: max value of a derivative of the field. Finf: max value of the absolute value of a
derivative of the field (computed using Fmin and Fmax).
First compute the derivative of a scalar field F in a given direction at a given order and on a given backend out of place in a specific output scalar field dF. The derivative is then possibly scaled by another field/parameter/value A.
After the scaled derivative has been computed, compute user requested statistics (min and max values) on this new field and scale those statistics by other scaling parameters stored in coeffs.
- Compute derivative
dF = alpha * d^n(F)/dXj**n
- where F is an input field
dF is an output field (by default a temporary field). n = derivative order > 0 alpha = A, where A is a Field, a Parameter or a scalar. Fmin = created or supplied TensorParameter. Fmax = created or supplied TensorParameter. Finf = created or supplied TensorParameter. Smin = coeffs[‘Fmin’] Smax = coeffs[‘Fmax’] Sinf = coeffs[‘Finf’]
- Statistics are only computed if explicitely requested by user,
unless required to compute another user-required statistic, see Notes.
- Parameters:
F (hysop.field.continuous_field.Field) – Continuous field as input.
dF (hysop.field.continuous_field.Field, optional) – Continuous field to be written. Some backend may allow inplace differentiation. By default a temporary scalar field is created, which means that the computation of the derivative may be discarded after this operator has been applied because of temporary buffer sharing between operators.
A (numerical value, ScalarParameter or Field, optional) – Scaling field/parameter/value for convenience. Defaults to no scaling.
derivative (int, optional) – Which derivative to generate. Defaults to 1.
direction (int, optional) – Directions in which to take the derivative. Defaults to 0.
F... (TensorParameter) – The output parameters that will contain the statistics. At least one statistic should be specified (either by boolean or TensorParameter). TensorParameters should be of shape (1,). If set to True, the TensorParameter will be generated automatically. Autogenerated TensorParameters that are not required by the user (ie. left to None or False during __init__) are, if required, generated but set to be quiet. Autogenerated parameters can be retrieved using the ‘Fmin’, ‘Fmax’ and ‘Finf’ attributes.
all_quiet (bool, optional defaults to False) – Set all autogenerated TensorParameter views to be quiet.
coeffs (dict of array like of coefficients, optional) – Optional scaling of the statistics. Scaling factor should be a scalar or an array-like of scalars for each components. If not given, defaults to 1 for all statistics.
name (str, optional) – Name of this operator.
pretty_name (str, optional) – Pretty name of this operator.
pbasename (str, optional) – Parameters basename for created parameters. Defaults to field.name.
ppbasename (str, optional) – Parameters pretty basename for created parameters. Defaults to pbasename.
variables (dict, optional) – Dictionary of fields as keys and topologies as values.
implementation (hysop.constants.Implementation, optional) – Specify underlying backend implementation. Target implementation, should be contained in available_implementations(). If None, implementation will be set to default_implementation().
base_kwds (dict, optional) – Base class keyword arguments as a dictionnary.
kwds – Extra keyword arguments passed towards operator backend implementation.
Attributes
-----------
F... – All generated tensor parameters. Unused statistics are set to None.
Notes
- About statistics:
- Finf requires to compute Fmin and Fmax and will have value:
Finf = Sinf * max( abs(Smin*Fmin), abs(Smax*Fmax))
where Sinf, Smin and Smax are the scaling coefficients defined in coeffs.
- apply(**kwds)¶
Abstract method that should be implemented. Applies this node (operator, computational graph operator…).